package org.example.springaop02.allproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyUtils {


    public static Object proxyCreate(Object obj){
        Object object = Proxy.newProxyInstance(obj.getClass().getClassLoader(),
                obj.getClass().getInterfaces(), new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println("代理了");
                        Object result = method.invoke(obj, args);
                        return result;
                    }
                });
        return object;

    }
}
